1. Field of the Invention
The present invention relates generally to software processing, and more particularly, to methods and systems for improving the detection of deprecated methods and classes implemented in computer software specifications.
2. Description of the Related Art
As the use of computer software in carrying out daily tasks has been increasing rapidly, so has the constant demand to enhance computer software performance. Consistently, computer programmers and software developers have been creating new software applications or modifying the existing software applications to arrive at a new version, hoping to eliminate all existing deficiencies.
At times, creating a new version of the software requires adding of new lines of source code, while in others certain portions of the source code are deprecated in the new version of the code. As used herein, “deprecate,” means marking a portion of the source code as being no longer in use. By way of example, deprecating a portion of the source code may involve deprecating certain elements or attributes implemented in the software source code (e.g., a class, a method, a library, an object, an application programming interface (“API”), etc.) In such situation, the deprecated element or attribute is marked as such, by for example, including a comment in the source code, warning the programmers, developers, and users of the deprecated status of the element or attribute.
Ideally, software source code should not include any deprecated elements or attributes. That is, all elements and attributes marked as deprecated should be deleted. Although preferable, such solution is not feasible due to intricate internal dependencies of the elements and attributes in the software source code. For instance, deleting an element or attribute can render all internal elements and attributes dependent on the deprecated element nonfunctional.
As an alternative to deleting all deprecated methods, thus far, the deprecated elements and attributes or their use have been detected by compilers during the source code compilation. For instance, certain compilers have been designed to recognize and flag the deprecated elements and attributes thus warning the users of implementing a deprecated element or attribute. However, several problems can be associated with detection of deprecated elements and attributes during compile time.
First is the “legacy problem” wherein the source code is compiled using an old version of a library (a library in which the method has not been deprecated) and then is run on a newer version of the library (a library in which the method has been flagged deprecated). In such situation, the usage of the deprecated method during run time cannot be detected.
The second drawback is the “reflection problem” in which a method or a class is invoked during run time. An example of such problem is using of a “reflection method” in which a method or a class is invoked by name, using a string, during the running of a program. Class.forName(), Class,newInstance(), and Constuctor.newInstance() are exemplary methods which create new instances of objects, Method.invoke() is an exemplary method which invokes a method in an object dynamically at runtime.
Third, is the “inheritance problem” in which a child method is deprecated while the method in the parent class is not. In such situation, some programming languages, such as JAVA, allow the method that depends on the object type (e.g., parent or child class) to get invoked at runtime. This is referred to as polymorphism in Object Oriented terminology.
Next is the problem of “user carelessness” in which users choose to ignore compiler warnings regarding the calling of a deprecated method. Furthermore, except generating a simple warning, the compilers and conventional computer systems are incapable of restricting access to deprecated elements and attributes.
One solution would be to manually search through the source code to find all references to deprecated elements (e.g., classes and methods) and physically remove them from the source code. However, this manual search is extremely time consuming and cost prohibitive. Besides, merely eighty percent of such deprecated elements and attributes can be located and removed through manual search of the source code. This occurs as some programming languages such as JAVA, classes and methods can be created and invoked at runtime (e.g., getting a method name as a string from the user, calling the method on an object, etc.). Such methods and classes cannot be detected by examining the source code, since the method to be invoked and detected is not known till the program is executed.
In view of the foregoing, there is a need for a flexible methodology and system for improving the detection and controlling access to deprecated elements and attributes in software specifications.